/// [Digit cancelling fractions](https://projecteuler.net/problem=33)
use problem_33::Fraction;

fn main() {
    let mut rst = Fraction::new(1, 1);
    for y in 10..100 {
        for x in 10..y {
            let f = Fraction::new(x, y);
            if f.is_non_trivial() {
                println!("{}", f);
                rst *= f;
            }
        }
    }
    println!("The mul is {}, reduce is{}", rst, rst.reduce());
}

#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn is_non_trivial() {
        assert_eq!(Fraction::new(49, 98).is_non_trivial(), true);
        assert_eq!(Fraction::new(30, 50).is_non_trivial(), false);
    }
    #[test]
    fn reduce() {
        assert_eq!(Fraction::new(49, 98).reduce().unpack(), (1, 2));
        assert_eq!(Fraction::new(30, 50).reduce().unpack(), (3, 5));
    }
}
